<!-- 物资退还 -->
<template>
	<view>
		<view class="p-3" v-if="dataList.length>0">
			<u-list @scrolltolower="loadMore" style="height:calc(100vh - 135rpx)">
				<view v-for="i in dataList" :key="i.id" class="bt-block py24px30 mb-3" @tap="gotoDetail(i)">
					<view class="flex justify-between">
						<view>
							<bg-desc label="物资名称" :value="i.materialName"></bg-desc>
							<bg-desc label="退还人" :value="i.createUserName"></bg-desc>
							<bg-desc label="退还时间" :value="i.createTime"></bg-desc>
						</view>
						<view>
							<u--image width="154rpx" height="154rpx" src="/static/over.jpg"></u--image>
						</view>
					</view>
				</view>
			</u-list>
		</view>
		<u-empty v-else></u-empty>
	</view>
</template>

<script>
	import { returnList } from '../../../api/apply'
	export default {
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url:"/pages/more/return/return"
			})
		},
		data() {
			return {
				params:{
					status:1,
					pageNum:1,
					pageSize:10,
				},
				total:0,
				dataList:[]
			}
		},
		mounted() {
			this.getData()
			uni.$on('refresh-page', ()=>{
				this.dataList = []
				this.params.pageNum = 1
				this.getData()
			})
		},
		methods: {
			getData(){
				returnList(this.params).then(res=>{
					this.dataList = [...this.dataList, ...res.data.rows]
					this.total = res.data.total
				})
			},
			loadMore(){
				if(this.dataList.length<this.total){
					this.params.pageNum += 1
					this.getData()
				}
			},
			gotoDetail(i){
				uni.navigateTo({
					url:"/pages/more/return/detail?id="+i.id
				})
			},
			getCover(data){
				if(Array.isArray(data)){
					if(data.length >0){
						return this.getImgUrl(data[0])
					}
				} else {
					let _data = String(data).split(',')
					if(_data.length >0){
						return this.getImgUrl(_data[0])
					}
				}
			},
			getImgUrl(){
				
			}
		}
	}
</script>

<style>

</style>
